package com.yang.po;

import com.yang.bean.beanfactory.impl.DefaultListableBeanFactory;
import com.yang.bean.resource.ClassPathResource;
import com.yang.bean.xml.XMLBeanDefinitionReader;

import java.io.InputStream;

/**
 * @Description:
 * @author: Yang Qiang
 * @create: 2021-11-08 22:28
 */
public class Test {
    public static void main(String[] args) {
        String location = "bean.xml";

        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        XMLBeanDefinitionReader xmlBeanDefinitionReader = new XMLBeanDefinitionReader(beanFactory);

        ClassPathResource classPathResource = new ClassPathResource(location);

        InputStream inputStream = classPathResource.getInputStream();

        xmlBeanDefinitionReader.loadBeanDefinition(inputStream);

        Role role = (Role)beanFactory.getBean("role");
        System.out.println(role);

        User user = (User) beanFactory.getBean("user");
        System.out.println(user);
    }

}
